<link href="$!webPath/resources/style/common/css/window.css" type="text/css" rel="stylesheet" />
<script>
var swf_upload;
var already_upload=0;
jQuery(document).ready(function(){	
	 var settings_object = {//定义参数配置对象
        upload_url : "$!webPath/seller/swf_upload.htm",
            flash_url : "$!webPath/resources/flash/swfupload.swf",
            file_post_name : "imgFile",
            post_params : {
              "user_id" : "$!user.id"
            },
            use_query_string : false,
            requeue_on_error : false,
            file_types : "$!imageSuffix",
            file_types_description: "相册图片",
            file_size_limit : "$!config.imageFilesize",
            file_upload_limit : 0,
            file_queue_limit : 0,
            debug : false,
            prevent_swf_caching : true,
            preserve_relative_urls : false,
            button_placeholder_id : "upload_imgs",
            button_image_url : "$!webPath/resources/style/common/images/upload.jpg",
            button_width : 160,
            button_height : 28,
            button_text : "<b></b> <span class='upload_text'>选择上传相册图片</span>",
            button_text_style : ".upload_text { color: #666666;font-size:12px;margin-left:40px; }",
            button_text_left_padding : 3,
            button_text_top_padding : 5,
            button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
            button_disabled : false,
            button_cursor : SWFUpload.CURSOR.HAND,
            button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
			file_dialog_start_handler:fileDialogStart,
			file_dialog_complete_handler:fileDialogComplete,
            upload_start_handler:upload_start_handler,
            upload_success_handler:uploadSuccess,
			upload_complete_handler:uploadComplete
			
    };   
    swf_upload = new SWFUpload(settings_object);//实例化一个SWFUpload，传入参数配置对象
	function fileDialogStart(){

	}
	function fileDialogComplete(numFilesSelected, numFilesQueued) {
       jQuery("#img_select_info").show();
	   jQuery("#img_desc_info").text("本次共选择"+numFilesSelected+"图片，"+this.getStats().files_queued+"张等待上传");
    }
	function upload_start_handler(){
	  jQuery("#upload_wait").show();
	}
	function uploadSuccess(file, serverData){//单个图片上传成功
	  var obj=eval("("+serverData+")");
	  var stats = this.getStats(); 
	  if(obj.url!=""){
	   
	  }else{
	    alert("您的店铺图片空间不足，请选择升级店铺或删除相册图片！");
	  }
	}
	function uploadComplete(file) {
	try {
		if (this.getStats().files_queued == 0) {
           jQuery("#upload_wait").hide();
		   alert("成功上传"+(already_upload+1)+"张图片！");
		   window.location.href="$!webPath/seller/album.htm";
		} else {	
		    already_upload=already_upload+1;
		    var count=this.getStats().files_queued;
			if(count<0)count=0;
			jQuery("#img_desc_info").text("正在上传第"+(already_upload+1)+"张,还剩下"+count+"张等待上传"); 
		    this.startUpload();
		}
	} catch (ex) {
		this.debug(ex);
	}
	}
});
function upload_img(){
  var upload_album_id=jQuery("#upload_album_id").val();
  swf_upload.addPostParam("album_id",upload_album_id); 
  jQuery("#img_desc_info").text("正在上传第1张,还剩下"+(swf_upload.getStats().files_queued-1)+"张等待上传"); 
  swf_upload.startUpload();
}
</script>
<form action="$!webPath/seller/album_save.htm" method="post" id="theForm">
<table style="float:left;" width="100%" border="0" cellspacing="0" cellpadding="0" class="box_table">
    <tr>
      <td width="120" align="right" class="hui_table"><input name="id" type="hidden" id="id" value="$!obj.id" />
      上传至：</td>
      <td align="left"><span class="dia_txt">
         <select name="upload_album_id" id="upload_album_id">
             #foreach($obj in $objs)
             <option value="$!obj.id">$!obj.album_name</option>
             #end
            </select>
      </span></td>
    </tr>
    <tr id="img_select_info" style="display:none;">
      <td align="right" class="hui_table">图片信息：</td>
      <td align="left"><span id="img_desc_info"></span></td>
    </tr>
    <tr>
      <td width="120" align="right" class="hui_table">选择图片：</td>
      <td align="left"><span id="upload_imgs"></span></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><span class="inputbtn">
        <input type="button" value="上传" style="cursor:pointer;" onclick="upload_img();"/>
        <img src="$!webPath/resources/style/common/images/wait.gif" style="display:none;" id="upload_wait" />
        <input name="currentPage" type="hidden" id="currentPage" value="$!currentPage" />
        </span></td>
    </tr>
  </table>
</form>
